package com.macro.mall.controller;

import cn.hutool.core.util.ObjectUtil;
import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.PmsProductQueryParam;
import com.macro.mall.mapper.OmsCartItemMapper;
import com.macro.mall.model.PmsProduct;
import com.macro.mall.model.request.ProductBatchGetRequest;
import com.macro.mall.model.request.ProductGetRequest;
import com.macro.mall.model.response.ProductBatchGetResponse;
import com.macro.mall.model.response.ProductGetResponse;
import com.macro.mall.model.vo.product.ProductDetailVo;
import com.macro.mall.model.vo.product.ProductListVo;
import com.macro.mall.service.ProductSyncService;
import com.macro.mall.service.XhsProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

@Controller
@Api(tags = "PmsProductController")
@Tag(name = "PmsProductController", description = "小红书商品管理")
@RequestMapping("/xhsproduct")
public class XhsProductController {

    @Resource
    private XhsProductService xhsProductService;


    @Resource
    private ProductSyncService productSyncService;



    //("批量获取商品信息")
    @PostMapping("/getProductList")
    public CommonResult getProductList(@RequestBody ProductBatchGetRequest request) {
        return CommonResult.success(productSyncService.getProductList(request));
    }



//
//    @ApiOperation("查询小红书商品")
//    @RequestMapping(value = "/list", method = RequestMethod.GET)
//    @ResponseBody
//    public CommonResult batchGetProducts(PmsProductQueryParam productQueryParam,
//                                                    @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
//                                                    @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
//        ProductBatchGetResponse productBatchGetResponse = xhsProductService.batchGetProducts(productQueryParam, pageSize, pageNum);
//        return CommonResult.success();
//    }




    @ApiOperation("批量获取商品信息")
    @RequestMapping(value = "/batch-get", method = RequestMethod.POST)
    @ResponseBody
    public ProductBatchGetResponse batchGetProducts(@RequestBody ProductBatchGetRequest request) {
        return productSyncService.batchGetProducts(request);
    }





    @ApiOperation("查询商品详情页")
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<ProductDetailVo> getDetailProduct(Integer id) {

        return CommonResult.success(productSyncService.getDetailProduct(id));
    }





}
